﻿<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="{{asset('admin/static/h-ui/css/H-ui.min.css')}}" />
<link rel="stylesheet" type="text/css" href="{{asset('admin/static/h-ui.admin/css/H-ui.admin.css')}}" />
<link rel="stylesheet" type="text/css" href="{{asset('admin/lib/Hui-iconfont/1.0.8/iconfont.css')}}" />
<link rel="stylesheet" type="text/css" href="{{asset('admin/static/h-ui.admin/skin/default/skin.css')}}" id="skin" />
<link rel="stylesheet" type="text/css" href="{{asset('admin/static/h-ui.admin/css/style.css')}}" />
<style>
	.pull-right{
		float: right !important;
	}
	.pagination{
		display: inline-block;
	    padding-left: 0;
	    margin: 20px 0;
	    border-radius: 4px;
	}
	.pagination > li{display: inline;}
	.pagination > li > a{
	    margin-left: 0;
		border-top-left-radius: 4px;
		border-bottom-left-radius: 4px;
	    position: relative;	
	    float: left;
	    padding: 6px 12px;
        line-height: 1.42857143;
	    color: #337ab7;
	    text-decoration: none;
	    background-color: #fff;
	    border: 1px solid #ddd;
	}
	.pagination > li > span{
	    margin-left: 0;
		border-top-left-radius: 4px;
		border-bottom-left-radius: 4px;
	    position: relative;	
	    float: left;
	    padding: 6px 12px;
        line-height: 1.42857143;
	    color: #337ab7;
	    text-decoration: none;
	    background-color: #fff;
	    border: 1px solid #ddd;
	}
	#adds{
		display: none;
	}
</style>
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>友情链接</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 友情链接 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<button type="submit" class="btn btn-success" id="addBtn" name="" ><i class="Hui-iconfont">&#xe600;</i> 添加友情链接</button>

	<div id="adds" class="text-c">
		<form class="Huiform" method="post" action="system-friendlink-add">
			<input type="hidden" name="_token" value="{{ csrf_token() }}" />
			<input type="text" placeholder="网站名称" name="name" value="" class="input-text" style="width:120px">
			<input type="text" placeholder="网站路径" name="url" value="" class="input-text" style="width:200px">
			<input type="text" placeholder="网站备注" name="content" value="" class="input-text" style="width:200px">
			<span class="btn-upload form-group">
			</span> <button type="submit" class="btn btn-success" id="" name="" ><i class="Hui-iconfont">&#xe600;</i> 确认添加</button>
		</form>
	</div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-sort">
			<thead>
				<tr class="text-c">
					<th width="70">ID</th>
					<th width="120">网站名称</th>
					<th width="120">网站路径</th>
					<th width="120">网站备注</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
			@foreach($list as $k)
				<tr class="text-c">
					<th class="id">{{ $k->id }}</th>
					<td class='name'>{{ $k->name }}</td>
					<td class='http_address'>{{ $k->http_address }}</td>
					<td class='content'>{{ $k->content }}</td>
					<th class="f-14 product-brand-manage">
						<a style="text-decoration:none" class="ml-5"  onclick="admin_del(this,{{$k->id}})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
					</th>
				</tr>
			@endforeach
			</tbody>
		</table>
		<div class="pull-right">
		</div>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="{{asset('admin/lib/jquery/1.9.1/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{asset('admin/lib/layer/2.4/layer.js')}}"></script>
<script type="text/javascript" src="{{asset('admin/static/h-ui/js/H-ui.min.js')}}"></script>
<script type="text/javascript" src="{{asset('admin/static/h-ui.admin/js/H-ui.admin.js')}}"></script> <!--/_footer 作为公共模版分离出去-->
<script>
function admin_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'GET',
			url: './system-friendlink-del?id='+id,
			dataType: 'json',
			success: function(data){
				//此处请求后台程序，下方是成功后的前台处理……
				layer.msg('已删除!',{icon: 5,time:1000});
				window.location.reload();
			},
			error:function(data) {
				console.log(data.msg);
			},
		});	

		
	});
}

//添加按钮点击事件
$('#addBtn').click(function () {
	console.log($('#adds').css('display'));

	if($('#adds').css('display')=='none'){
		$('#adds').css('display', 'inline');
	}else{
		$('#adds').css('display', 'none');
	}

	

});

$(document).on("dblclick","td",function(){
			//双击将td改变成input并取得默认值
			//获取点击的是什么数据类型
			var type = $(this).attr('class');
			$(this).attr('class');
			$(this).replaceWith('<td class='+type+'><input autofocus value='+$(this).text()+'></td>');

			//input失去焦点
			// $('input').focusout(function() {
			$(document).on("focusout","input",function(){
				
				var ajax = new XMLHttpRequest;
				var that = this;
				if (this.value.length<=0) {
					layer.msg('值不能为空!',{icon: 5,time:1000});
					return false;
				}

				//获取要修改的ID号\
				var id = $(this).parent().parent().children('.id').text();

				//获取input内的值
				var chg = $(this).val();
				
				//打开PHP
				ajax.open('get', './system-friendlink-edit?id='+id+'&'+type+'='+chg,true);
				ajax.send();

				//改变tr内容
				$(this).replaceWith($(this).val());
				// window.location.reload();
			//--------尝试代码---------------------------------
			});
		});
</script>

</body>
</html>